package org.p2psimulator.entity.overlaynetwork;

import org.p2psimulator.engine.Environment;
import org.p2psimulator.entity.OverlayNetwork;

public enum OverlayType {

    GNUTELLA_OVERLAY("GnutellaOverlay"), CHORD_OVERLAY("ChordOverlay"), HYBRID_OVERLAY("HibridOverlay"), SUPERPEER_OVERLAY("Superpeer");
    String name;

    OverlayType(String name) {
        this.name = name;
    }

    public OverlayNetwork getOverlayNetworkInstance(Environment env) {

        switch (this) {
            case GNUTELLA_OVERLAY:
                return new GnutellaOverlay(env);

            case CHORD_OVERLAY:
                return new ChordOverlay(env);
            case HYBRID_OVERLAY:
                return new HibridOverlay(env);
            case SUPERPEER_OVERLAY:
                return new SuperpeerOverlay(env);
            default:
                throw new AssertionError("Overlay Inexistente");
        }
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
